import request from '@/api/request'
import { banner, hotData } from '../store/recommend'

interface responseData {
    code: number
}

export interface bannersResponseData extends responseData {
    banners: banner[]
}

export interface hotRecommendResponseData extends responseData {
    hasTaste: boolean
    category: number
    result: hotData[]
}

export async function getBanners() {
    try {
        const response: bannersResponseData = await request.get('/banner')
        return response
    } catch (error) {
        console.error('Error fetching banners:', error)
        return [] // 返回一个空数组以防止程序崩溃
    }
}

export async function getHotRecommend() {
    try {
        const response: hotRecommendResponseData = await request.get('/personalized')
        return response
    } catch (error) {
        console.error('Error fetching personalized:', error)
        return [] // 返回一个空数组以防止程序崩溃
    }
}
